"use strict";
var merge = require("merge");
var config = require("../server.json");
var obj = null;
// const process = require('process');
var configLocal = {};
var basePath = null;
const FileUtils = require('./util/FileUtils')
const path = require('path');
try {
  configLocal = require("../localserver.json")
}
catch (e) {
  console.info("local server file is not exits, use default config...");
  configLocal = {};
}
// process.cwd() + '/uploads'
console.log(FileUtils.getPath('/lx/zliuxia.github.io/_posts'))

module.exports = {
  upload: {
    path: FileUtils.getPath('/lx/zliuxia.github.io/img')
  },
  getConfig: function () {
    if (!obj) {
      obj = merge(config, configLocal);
    }
    return obj;
  },
  getBase(){
    if (basePath) {
      return basePath;
    }
    let config = this.getConfig();
    let p = config.base;
    if (typeof p === "string") {
      p = p.trim();
    }
    basePath = !p ? "/" : p;
    return basePath;
  }
};
